package com.estate.service.region;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.estate.mapper.RegionMapper;
import com.estate.pojo.Detail;
import com.estate.pojo.Region;

@Service
public class RegionServiceImpl implements RegionService {
	
	@Autowired
	private RegionMapper regionMapper;

	//添加区域
	@Override
	public Boolean addRegion(Region region) {
		int num = 0;
		try {
			num = regionMapper.insert(region);
			if(num>0){
				return true;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}

	@Override
	public Integer findRegionIdByDetilId(Integer detilId) {
		Integer num = 0;
		try {
			num = regionMapper.findRegionIdByDetilId(detilId);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return num;
	}
	
	@Override
	public List<Region> findRegionByDetilId(Integer detilId) {
		List<Region> regionlist = new ArrayList<>();
		try {
			regionlist = regionMapper.findRegionByDetilId(detilId);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return regionlist;
	}

	@Override
	public List<Region> findCodeByProId(Integer ProId) {
		List<Region> regionCodelist = new ArrayList<>();
		try {
			regionMapper.findCodeByProId(ProId);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return regionCodelist;
	}
	
}
